package com.edu.exam.enums.grading;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 审计节点状态枚举
 */
public enum AuditNodeStatus implements BaseEnum {

    /**
     * 未激活
     */
    INACTIVE("INACTIVE", "未激活"),

    /**
     * 激活
     */
    ACTIVE("ACTIVE", "激活"),

    /**
     * 运行中
     */
    RUNNING("RUNNING", "运行中"),

    /**
     * 已完成
     */
    COMPLETED("COMPLETED", "已完成"),

    /**
     * 失败
     */
    FAILED("FAILED", "失败"),

    /**
     * 已跳过
     */
    SKIPPED("SKIPPED", "已跳过"),

    /**
     * 已取消
     */
    CANCELLED("CANCELLED", "已取消");

    private final String code;
    private final String description;

    AuditNodeStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    /**
     * 从代码创建枚举实例
     *
     * @param code 枚举代码
     * @return 对应的枚举实例
     */
    public static AuditNodeStatus fromCode(String code) {
        for (AuditNodeStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown audit node status code: " + code);
    }

    @Override
    public String toString() {
        return description;
    }
}